package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataVerification;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysQuarterly;
import com.ruoyi.system.service.ISysQuarterlyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 季刊内容Controller
 *
 * @author ruoyi
 * @date 2022-03-29
 */
@RestController
@RequestMapping("/system/quarterly")
public class SysQuarterlyController extends BaseController
{
    @Autowired
    private ISysQuarterlyService sysQuarterlyService;

    /**
     * 查询季刊内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:quarterly:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysQuarterly sysQuarterly)
    {
        startPage();
        List<SysQuarterly> list = sysQuarterlyService.selectSysQuarterlyList(sysQuarterly);
        return getDataTable(list);
    }

    /**
     * 导出季刊内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:quarterly:export')")
    @Log(title = "季刊内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysQuarterly sysQuarterly)
    {
        List<SysQuarterly> list = sysQuarterlyService.selectSysQuarterlyList(sysQuarterly);
        ExcelUtil<SysQuarterly> util = new ExcelUtil<SysQuarterly>(SysQuarterly.class);
        util.exportExcel(response, list, "季刊内容数据");
    }

    /**
     * 获取季刊内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:quarterly:query')")
    @GetMapping(value = "/{quarterlyId}")
    public AjaxResult getInfo(@PathVariable("quarterlyId") Long quarterlyId)
    {
        return AjaxResult.success(sysQuarterlyService.selectSysQuarterlyByQuarterlyId(quarterlyId));
    }

    /**
     * 新增季刊内容
     */
    @DataVerification(name = "添加季刊内容")
    @PreAuthorize("@ss.hasPermi('system:quarterly:add')")
    @Log(title = "季刊内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysQuarterly sysQuarterly)
    {
        return toAjax(sysQuarterlyService.insertSysQuarterly(sysQuarterly));
    }

    /**
     * 修改季刊内容
     */
    @DataVerification(name = "修改季刊内容")
    @PreAuthorize("@ss.hasPermi('system:quarterly:edit')")
    @Log(title = "季刊内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysQuarterly sysQuarterly)
    {
        return toAjax(sysQuarterlyService.updateSysQuarterly(sysQuarterly));
    }

    /**
     * 删除季刊内容
     */
    @PreAuthorize("@ss.hasPermi('system:quarterly:remove')")
    @Log(title = "季刊内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quarterlyIds}")
    public AjaxResult remove(@PathVariable Long[] quarterlyIds)
    {
        return toAjax(sysQuarterlyService.deleteSysQuarterlyByQuarterlyIds(quarterlyIds));
    }
}
